# -*- coding: utf-8 -*-

'''
@project : FaceRecognition_v7
@FileName: tv1
@Author  :linych 
@Time    :2021/2/18 20:16
@Desc  : 
'''

import ffmpeg
import numpy as np
from matplotlib import pyplot as plt

vpath = r'C:\Users\lyc\Desktop\enter1.mp4'

probe = ffmpeg.probe(vpath)
video_info = next(s for s in probe['streams'] if s['codec_type'] == 'video')
width = int(video_info['width'])
height = int(video_info['height'])
num_frames = int(video_info['nb_frames'])

out, err = (
    ffmpeg
    .input(vpath)
    .output('pipe:', format='rawvideo', pix_fmt='rgb24')
    .run(capture_stdout=True)
)
video = (
    np
    .frombuffer(out, np.uint8)
    .reshape([-1, height, width, 3])
)


plt.imshow(video[0,:,:,:])